package com.example.dts.model;

import com.example.dts.constant.StaticConstant;
import com.example.dts.listener.BaseEntityListener;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;


@EntityListeners(value = {BaseEntityListener.class})
@MappedSuperclass
@Getter
@Setter
public class BaseEntity implements Serializable {

    private static final long serialVersionUID = 5231164630331357277L;

    /**
     * 创建人id
     */
    @Column(name = "create_user_id")
    private String createUserId;

    /**
     * 创建时间
     */
    @Column(name = "create_date")
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = StaticConstant.DOA_DATE_FORMAT, timezone = StaticConstant.GMT8)
    private Date createDate = new Date();

    /**
     * 最后一次更新人id
     */
    @Column(name = "last_update_user_id")
    private String lastUpdateUserId;

    /**
     * 最后一次更新时间
     */
    @Column(name = "last_update_date")
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = StaticConstant.DOA_DATE_FORMAT, timezone = StaticConstant.GMT8)
    private Date lastUpdateDate = new Date();

    /**
     * 是否已删除
     */
    @Column(name = "deleted")
    private Boolean deleted = false;
}
